package java_thinking.unit_16._16_2_3;

import java_thinking.unit_16.BerylliumSphere;

/**
 * @Desc:
 * @author: cww
 * @DateTime: 2019/4/8 20:42
 */

public class E01_ArrayInitialization {
    static void hide(BerylliumSphere[] s) {
        System.out.println("Hiding " + s.length + " sphere(s)");
    }
    static BerylliumSphere[] c;
    public static void main(String[] args) {
        // Dynamic aggregate initialization:
        hide(new BerylliumSphere[]{ new BerylliumSphere(),
                new BerylliumSphere() });
        // The following line produces a compilation error.
        //! hide({ new BerylliumSphere(),new BerylliumSphere(), new BerylliumSphere() });
        // Aggregate initialization:
        /**
         * 聚集初始化
         */
        BerylliumSphere[] d = { new BerylliumSphere(),
                new BerylliumSphere(), new BerylliumSphere() };
        hide(d);
        // Dynamic aggregate initialization is redundant
        // in the next case:
        BerylliumSphere[] a = new BerylliumSphere[]{
                new BerylliumSphere(), new BerylliumSphere() };
        hide(a);
        /**
         * 动态聚集初始化
         */
        c = new BerylliumSphere[]{
                new BerylliumSphere(), new BerylliumSphere() };
    }
}
